package com.fancy.learncenter.ui.activity;

import android.os.Bundle;
import android.widget.EditText;

import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.BaseBean;
import com.fancy.learncenter.bean.CartoonTeacherWorkListDataBean;
import com.fancy.learncenter.net.CustomNetCallBack;
import com.fancy.learncenter.net.CustomNetSubscriber;
import com.fancy.learncenter.net.HttpMehtod;
import com.fancy.learncenter.ui.activity.base.BaseActivity;
import com.fancy.learncenter.utils.NetUtil;
import com.fancy.learncenter.utils.ToastUtil;
import com.fancy.learncenter.utils.Utils;

import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import okhttp3.ResponseBody;
import retrofit2.Response;

public class CartoonAddSutendActivity extends BaseActivity {

    String classIO;
    @Bind(R.id.content)
    EditText content;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cartoon_add_sutend, Status.STATUS);
        ButterKnife.bind(this);
        initToolbar("添加学生");
        classIO = getIntent().getStringExtra(CartoonTeacherClassDetailActivity.CLASS_ID_KEY);

    }

    String classId;

    @OnClick(R.id.add_bt)
    public void onViewClicked() {

        Map<String, Object> map = new HashMap<>();
        map.put("classId", classId);
        map.put("mobile", content.getText().toString());

        HttpMehtod.getInstance().queryStudent(map, new CustomNetSubscriber(this, true) {
            @Override
            public void onNext(Response<ResponseBody> responseBodyResponse) {

                BaseBean<CartoonTeacherWorkListDataBean> baseBean = Utils.fromJsonObject(NetUtil.getResResult(responseBodyResponse), CartoonTeacherWorkListDataBean.class);
                CustomNetCallBack callBack = new CustomNetCallBack(getContext(), baseBean);
                callBack.setCallBack(new CustomNetCallBack.NetCallBack<CartoonTeacherWorkListDataBean>() {
                    @Override
                    public void success(CartoonTeacherWorkListDataBean dataBean) {
                        ToastUtil.show("创建成功");
                    }

                    @Override
                    public void fail(String errorCode) {


                    }
                }).dealData();
            }

        });
    }
}
